//
//  UIScrollView+QSRefreshHeaderFooter.m
//  DigitalEconomy_iOS
//
//  Created by Ding on 2020/3/19.
//  Copyright © 2020 DingC. All rights reserved.
//

#import "UIScrollView+QSRefreshHeaderFooter.h"

#import "QSRefreshHeader.h"
#import "QSRefreshFooter.h"

@implementation UIScrollView (QSRefreshHeaderFooter)
- (void)addRefreshHeaderWithRefreshingBlock:(void (^)(void))block {
    self.mj_header = [QSRefreshHeader headerWithRefreshingBlock:block];
}

- (void)addRefreshFooterWithRefreshingBlock:(void (^)(void))block {
    self.mj_footer = [QSRefreshFooter footerWithRefreshingBlock:block];
}

- (void)qs_endRefreshing {
    if (self.mj_header) {
        [self.mj_header endRefreshing];
    }
    if (self.mj_footer) {
        [self.mj_footer endRefreshing];
    }
}

- (void)qs_endRefreshingWithNoMoreData {
    if (self.mj_footer) {
        [self.mj_footer endRefreshingWithNoMoreData];
    }
}

- (void)qs_startRefreshing {
    if (self.mj_header) {
        [self.mj_header beginRefreshing];
        if (self.mj_footer) {
            [self.mj_footer resetNoMoreData];
        }
    }
}
@end
